// ************************************************************* //
//                                                               //
//        Copyright (C) 2015 by Socionext Inc.                   //
//        All rights reserved.                                   //
//        Socionext Inc. Proprietary and Confidential.           //
//                                                               //
// ************************************************************* //
/*****************************************************************************/
/**
 * @file netsec.h
 * @brief NETSEC driver
 * @note None
 * @attention None
 *
 */
/*****************************************************************************/
#ifndef __NETSEC_H
#define __NETSEC_H

/*----------------------------------------------------------------------*/
/* Definition															*/
/*----------------------------------------------------------------------*/
/* NETSEC Result */
#define D_NETSEC_OK					0			/**< OK	*/
#define D_NETSEC_ERR_OUTOFRANGE		1			/**< Out of Range	*/
#define D_NETSEC_ERR_TIMEOUT		2			/**< Timeout	*/
#define D_NETSEC_ERR_PARAM_NG		3			/**< Parameter NG	*/

/* NETSEC wait time */
#define NETSEC_WAIT_TIME			2000uL

/* Register value */
#define NETSEC_ENC_CTRL_SET	0x03000012		/**<	Encription Control Register
												bit[27:26] : b00   // big endian
												bit[25]    : b1    // little endian
												bit[24]    : b1    // host mode
												bit[16]    : b0    // register mode(hash only)
												bit[8]     : b0    // don't care
												bit[4]     : b1    // don't use hmac
												bit[3]     : b0    // don't care
												bit[2:0]   : b010  // hash only */

#define NETSEC_ENC_CTRL_END	0x02000012		/**<	Encription Control Register
												bit[27:26] : b00   // big endian
												bit[25]    : b1    // little endian
												bit[24]    : b0    // crypto mode
												bit[16]    : b0    // register mode(hash only)
												bit[8]     : b0    // don't care
												bit[4]     : b1    // don't use hmac
												bit[3]     : b0    // don't care
												bit[2:0]   : b010  // hash only */

#define NETSEC_INIT_CODE	0xFFFFFFFF		/**< initialize-value is arbitrary value. */
#define NETSEC_LAST_SHOT	0x00000000		/**< last-value is fixed to 0. */
#define NETSEC_HASH_256		0x3				/**< SHA-256 */
#define NETSEC_CMD_BASE		0x00000008		/**< the base value of the hash command */
#define NETSEC_HASH_DONE	(1 << 6)		/**< the completion of the hash calculation. */

//#define NETSEC_DEBUG

/*----------------------------------------------------------------------*/
/* Enumeration															*/
/*----------------------------------------------------------------------*/
// Nothing Special

/*----------------------------------------------------------------------*/
/* Structure															*/
/*----------------------------------------------------------------------*/
/** Hash Data */
typedef struct {
	unsigned long addr;		/**< data address */
	unsigned long size;		/**< data size */
} T_HASH_DATA;

/*----------------------------------------------------------------------*/
/* Function																*/
/*----------------------------------------------------------------------*/
extern int hash_calculate(unsigned int data_num, T_HASH_DATA data[], unsigned long hash_value[8]);

#endif
